package com.example.exam.config;

import com.example.exam.interceptor.UserInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.ArrayList;
import java.util.List;

/**
 * @author shishuqian
 * date 2021/5/12
 * time 22:56
 **/
//@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

   /* @Bean
    public UserInterceptor userInterceptor(){
        return new UserInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        List<String> patterns = new ArrayList();
        //放行路径
        patterns.add("/webjars/**");
        patterns.add("/druid/**");
        patterns.add("/swagger/**");
        patterns.add("/v2/api-docs");
        patterns.add("/swagger-ui.html");
        patterns.add("/swagger-resources/**");
        patterns.add("/user/login");  //登录
        patterns.add("/user/register");  //注册

        registry.addInterceptor(userInterceptor()).addPathPatterns("/**").excludePathPatterns(patterns);
    }*/
}
